
// export  let products=[
//     {id:1,name:'韩国三熹玉3CE彩妆香水专场',img:'../assets/header.jpg',num:80,price:1000},
//     {id:2,name:'阿迪达斯三叶草运动户外专场',img:'../assets/center.jpg',num:90,price:2000},
//     {id:3,name:'UGG专场',img:'../assets/bottom.jpg',num:80,price:3000},
//     {id:4,name:'伊芙丽eifini女装专场',img:'../assets/yfl.jpg',num:67,price:3000}
// ];

// export let cart=[];

export default {
    name:'product',
    products:[
            {id:1,name:'韩国三熹玉3CE彩妆香水专场',img:'../assets/header.jpg',num:80,price:1000},
            {id:2,name:'阿迪达斯三叶草运动户外专场',img:'../assets/center.jpg',num:90,price:2000},
            {id:3,name:'UGG专场',img:'../assets/bottom.jpg',num:80,price:3000},
            {id:4,name:'伊芙丽eifini女装专场',img:'../assets/yfl.jpg',num:67,price:3000}
        ],
    cart:[],

    addToCart:function(id){
        
        let inCart = false;
        this.cart.forEach(el=>{
            if(id==el.id){
                inCart=true;
                el.num++;
            }
        })
        if(inCart==false){
            this.products.forEach(el=>{
              if(el.id==id){
                  let product =el;
                  product.num=1;
                  this.cart.push(product);
              }
            })          
        }
        console.log(this.cart)
    },
    getCart(){
        return this.cart;
    },   
}



